package org.example.rabbitmq;

import org.example.config.RabbitmqOneConfig;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class sendMsg<T> implements sendUtil<T> {
    @Autowired
    @Qualifier(value = "oneRabbitTemplate")
    private RabbitTemplate rabbitTemplate;


    public void sendProblem(T codeEntity){

        if(codeEntity !=null){
            rabbitTemplate.convertAndSend(RabbitmqOneConfig.QUEUE_NAME,codeEntity);
        }

    }

    /**
     * 实现样例判题
     * @param entity
     */

    @Override
    public void sendCase(T entity) {
        if(entity !=null){
            rabbitTemplate.convertAndSend(RabbitmqOneConfig.RUN_CASE_QUEUE_NAME,entity);
        }
    }

}
